


// let xhr = new XMLHttpRequest()

class MyAjax {
	constructor(method, url, success) {
	    this.method = method
	    this.url = url
	    this.success = success
	}
	
	request() {
		let xhr = new XMLHttpRequest()
		xhr.open(this.method, this.url)
		xhr.send(null)
		// ....
	}
	
	get() {
		let xhr = new XMLHttpRequest()
		xhr.open("GET", this.url)
		xhr.send(null)
	}
}
// new MyAjax(method, url, success)
// new MyAjax(url, success).get()



// console.log(typeof Car) // function
const runingName = "runing"
// class Car {
// const MyCar = class Car {
const MyCar = class {
	constructor(brand, from) {
	    this.brand = brand
	    this.from = from
		// this.color = "red"
	}
	// color = "red";
	
	// runing() {
	[runingName]() {
		console.log(this)
		console.log("runing!!!")
	}
	
	// active() {
	static active() { // 静态方法, this指向当前的class
		console.log(this)
		console.log("变身")
	}
	
	/*get color() {
		return "#f00"
	}
	
	set color(val) {
		console.log(val)
	}*/
}

// MyCar.active()

const bmw = new MyCar("宝马!", "华晨")
const oooo = new MyCar("奥迪!", "一汽")
console.log(bmw)
// bmw.runing()
// bmw.active()
console.log(oooo)


// class 子类 extends 父类 {}
class RedCar extends MyCar {
	constructor(brand, from, color) {
		super(brand, from) // 给父类提供参数
	    this.color = color
	}
	
	runing() {
		console.log("重写runing")
	}
}
const mzd = new RedCar("马自达", "小日本", "混蛋红")
console.log(mzd)
mzd.runing()

console.log(mzd instanceof RedCar)
console.log(mzd instanceof MyCar)
console.log(oooo instanceof MyCar)
console.log(oooo instanceof RedCar)

// const bmw = new Car("宝马", "华晨")
// const oooo = new Car("奥迪", "一汽")

// console.log(bmw.color)
// bmw.color = "#000"
// console.log(bmw.__proto__)
// console.log(Car.prototype)
// console.log(Car.prototype.constructor)
// console.log(Car.prototype === bmw.__proto__)
// console.log(oooo)







